<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp" %>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>序号设定</title>
    
    <script type="text/javascript">
    	var dialog;
        var gridManager = null;
        $(function ()
        {
 
        	$(".l-toolbar-item").hover(
            	function (){
                   $(this).addClass("l-panel-btn-over");
               }, function (){
                   $(this).removeClass("l-panel-btn-over");
            });
            	
            $(".l-toolbar-item").click(function(){
            	toolbarBtnItemClick($(this));
            });
            
            $("#maingrid").ligerGrid({
                columns: [
                { display: '代码', name: 'sqId', align: 'left', width:'15%', minWidth: 60 },
                { display: '用途', name: 'sqTitle', width:'15%',minWidth: 120 },
                { display: '字轨', name: 'sqPrefix',width:'15%', minWidth: 120 },
                { display: '编码', name: 'sqFormat',width:'15%', minWidth: 120 },
                { display: '总长度', name: 'sqLength',width:'15%', minWidth: 120 }
                ], dataAction: 'server', url: '${ctx}/sequence/list', sortName: 'sqId',
                width: '100%', height: '100%', numPerPage:20,rownumbers:true,
                checkbox : true,
                heightDiff: -6
            });
             
            gridManager = $("#maingrid").ligerGetGridManager();

            $("#pageloading").hide();


        });


        
        function search(){
            if (!gridManager) return;
            var sqId = $("#sqId").val(); 
            var sqTitle = $.trim($("#sqTitle").val()); 
            gridManager.setOptions(
                { parms: [{ name: 'search_LIKE_sqTitle', value: sqTitle},{ name: 'search_LIKE_sqId', value: sqId}] }
            );
            gridManager.loadData(true);
        }
        
        function toolbarBtnItemClick(item) {
            switch (item.attr("toolbarid")) {
                case "add":
                	dialog=$.ligerDialog.open({url: '${ctx}/sequence/view/add?sqId=',height:400, width:850, showMax: true, showToggle: true, showMin: true, isResize: true, modal: true, title:"添加"});
                    break;
                case "detail":
                    var row = gridManager.getSelected();
                    if (!row){
                    	alert('请选择行');
                    }else{
                    	dialog=$.ligerDialog.open({url: '${ctx}/sequence/view/detail?sqId='+row.sqId,height:400, width:800, showMax: true, showToggle: true, showMin: true, isResize: true, modal: true, title:"详细"});
                    }
                    break;
                case "modify":
                    var row = gridManager.getSelected();
                    if (!row){
                    	alert('请选择行');
                    }else{
                    	dialog=$.ligerDialog.open({url: '${ctx}/sequence/view/modify?sqId='+row.sqId,height:400, width:800, showMax: true, showToggle: true, showMin: true, isResize: true, modal: true, title:"修改"});
                    }
                    break;
                case "delete":
                	remove();
                    break;
            }
        }

        function reload(){
        	gridManager.loadData();
        }
        
        function remove(){
            var data = gridManager.getCheckedRows();
            if (data.length == 0)
            	LG.tip('请选择行!');
            else
            {
                var checkedIds = [];
                $(data).each(function ()
                {
                    checkedIds.push(this.sqId);
                });
                $.ligerDialog.confirm('确定删除 吗?', function (flag)
                {
                	if(flag){
                        LG.ajax({
                            url: '${ctx}/sequence/delete',
                            loading: '正在删除中...',
                            data:{ids:checkedIds.join(',')},
                            success: function (result) {
                                LG.showSuccess(result.message);
                                reload();
                            },
                            error: function (result) {
                                LG.showError(result.message);
                            }
                        });
                	}

                }); 
            }
        }
        
        function saveDoneCallBack(){
        	dialog.close();
            gridManager.loadData(true);
        }
    </script>
</head>
<body style="padding:0px; overflow:hidden;"> 
<div class="l-loading" style="display:block" id="pageloading"></div> 

<div style=" width:100%" id="mainsearch">
    <div class="searchtitle">
        <span>搜索</span>
        <img src="${ctx}/static/icons/32X32/searchtool.gif"/>
        <div class="togglebtn"></div> 
    </div>
    <div style="margin-bottom:4px; margin-top:4px;" class="navline"></div>
    <div class="searchbox">
        <form class="l-form" id="formsearch" ligeruiid="formsearch">
        	<ul>
        		<li style="width:90px;text-align:left;">代码：</li>
        		<li style="width:180px;text-align:left;">
	        		<div class="l-text" style="width: 178px;">
	        			<input type="text" ligerui="{&quot;width&quot;:178}" id="sqId" ltype="text" class="field l-text-field" style="width: 174px;">
	        			<div class="l-text-l"></div>
	        			<div class="l-text-r"></div>
	        		</div>
        		</li>
        		<li style="width:40px;"></li>
        		<li style="width:90px;text-align:left;">用途：</li>
        		<li style="width:180px;text-align:left;">
	        		<div class="l-text" style="width: 178px;">
	        			<input type="text" ligerui="{&quot;width&quot;:178}" id="sqTitle" ltype="text" class="field l-text-field" style="width: 174px;">
	        			<div class="l-text-l"></div>
	        			<div class="l-text-r"></div>
	        		</div>
        		</li>
        		<li style="width:40px;"></li>
        		<li style="margin-right:8px">
        			<div style="width:60px" class="button button2 buttonnoicon" onclick="search()">
	        			<div class="button-l"> </div>
	        			<div class="button-r"> </div> 
	        			<span>查询</span>
        			</div>
        		</li>
        	</ul>
        	<div class="l-clear"></div>
        </form>
    </div>
</div>

<div class="l-panel-topbar l-toolbar" ligeruiid="ToolBar1000">
	<div class="l-toolbar-item l-panel-btn l-toolbar-item-hasicon" toolbarid="add">
		<span>新增</span>
		<div class="l-panel-btn-l"></div>
		<div class="l-panel-btn-r"></div>
		<img src="${ctx}/static/icons/silkicons/add.png">
	</div>
	<div class="l-bar-separator"></div>
	<div class="l-toolbar-item l-panel-btn l-toolbar-item-hasicon" toolbarid="modify">
		<span>修改</span>
		<div class="l-panel-btn-l"></div>
		<div class="l-panel-btn-r"></div>
		<img src="${ctx}/static/icons/silkicons/application_edit.png">
	</div>
	<div class="l-bar-separator"></div>
	<div class="l-toolbar-item l-panel-btn l-toolbar-item-hasicon" toolbarid="delete">
		<span>删除</span>
		<div class="l-panel-btn-l"></div>
		<div class="l-panel-btn-r"></div>
		<img src="${ctx}/static/icons/silkicons/delete.png">
	</div>
	<div class="l-bar-separator"></div>
	<div class="l-toolbar-item l-panel-btn l-toolbar-item-hasicon" toolbarid="detail">
		<span>查看</span>
		<div class="l-panel-btn-l"></div>
		<div class="l-panel-btn-r"></div>
		<img src="${ctx}/static/icons/silkicons/application_view_detail.png">
	</div>
	<div class="l-bar-separator"></div>
</div>

<div id="maingrid" style="margin:0; padding:0"></div>

<div style="display:none;"></div>
 
</body>
</html>
